package com.sqk.dxpro.dxsta;

import java.io.IOException;
import java.util.Iterator;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Reducer;

import com.sqk.dxpro.utils.TProperties;


public class DxStaOneReducer extends Reducer<Text,IntWritable,NullWritable,Text> {

	@Override
	protected void reduce(Text key, Iterable<IntWritable> values,
			Reducer<Text, IntWritable, NullWritable, Text>.Context context)
			throws IOException, InterruptedException {
		// TODO Auto-generated method stub
		
		Iterator<IntWritable> it = values.iterator();
		int sum = 0;
		while(it.hasNext()){
			IntWritable temp = it.next();
			int i = temp.get();
			sum+=i;
		}
		String ovalue = key.toString()+TProperties.getValue("outfilesplit")+sum;
		context.write(NullWritable.get(),new Text(ovalue));
	}

	
}
